<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GMemoryOutputStream: GIO Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GIO Reference Manual">
<link rel="up" href="streaming.html" title="Streaming I/O">
<link rel="prev" href="GMemoryInputStream.html" title="GMemoryInputStream">
<link rel="next" href="GBufferedInputStream.html" title="GBufferedInputStream">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#GMemoryOutputStream.description" class="shortcut">Description</a></span><span id="nav_hierarchy">  <span class="dim">|</span> 
                  <a href="#GMemoryOutputStream.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_interfaces">  <span class="dim">|</span> 
                  <a href="#GMemoryOutputStream.implemented-interfaces" class="shortcut">Implemented Interfaces</a></span><span id="nav_properties">  <span class="dim">|</span> 
                  <a href="#GMemoryOutputStream.properties" class="shortcut">Properties</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="streaming.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="GMemoryInputStream.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="GBufferedInputStream.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="GMemoryOutputStream"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="GMemoryOutputStream.top_of_page"></a>GMemoryOutputStream</span></h2>
<p>GMemoryOutputStream — Streaming output operations on memory chunks</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="GMemoryOutputStream.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="GMemoryOutputStream.html#GReallocFunc" title="GReallocFunc ()">*GReallocFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="GOutputStream.html" title="GOutputStream"><span class="returnvalue">GOutputStream</span></a> *
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-new" title="g_memory_output_stream_new ()">g_memory_output_stream_new</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="GOutputStream.html" title="GOutputStream"><span class="returnvalue">GOutputStream</span></a> *
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-new-resizable" title="g_memory_output_stream_new_resizable ()">g_memory_output_stream_new_resizable</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-get-data" title="g_memory_output_stream_get_data ()">g_memory_output_stream_get_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="../glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-get-size" title="g_memory_output_stream_get_size ()">g_memory_output_stream_get_size</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="../glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-get-data-size" title="g_memory_output_stream_get_data_size ()">g_memory_output_stream_get_data_size</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-steal-data" title="g_memory_output_stream_steal_data ()">g_memory_output_stream_steal_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="../glib-Byte-Arrays.html#GBytes"><span class="returnvalue">GBytes</span></a> *
</td>
<td class="function_name">
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-steal-as-bytes" title="g_memory_output_stream_steal_as_bytes ()">g_memory_output_stream_steal_as_bytes</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.properties"></a><h2>Properties</h2>
<div class="informaltable"><table class="informaltable" border="0">
<colgroup>
<col width="150px" class="properties_type">
<col width="300px" class="properties_name">
<col width="200px" class="properties_flags">
</colgroup>
<tbody>
<tr>
<td class="property_type"><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a></td>
<td class="property_name"><a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream--data" title="The “data” property">data</a></td>
<td class="property_flags">Read / Write / Construct Only</td>
</tr>
<tr>
<td class="property_type"><a href="../glib-Basic-Types.html#gulong"><span class="type">gulong</span></a></td>
<td class="property_name"><a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream--data-size" title="The “data-size” property">data-size</a></td>
<td class="property_flags">Read</td>
</tr>
<tr>
<td class="property_type"><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a></td>
<td class="property_name"><a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream--destroy-function" title="The “destroy-function” property">destroy-function</a></td>
<td class="property_flags">Read / Write / Construct Only</td>
</tr>
<tr>
<td class="property_type"><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a></td>
<td class="property_name"><a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream--realloc-function" title="The “realloc-function” property">realloc-function</a></td>
<td class="property_flags">Read / Write / Construct Only</td>
</tr>
<tr>
<td class="property_type"><a href="../glib-Basic-Types.html#gulong"><span class="type">gulong</span></a></td>
<td class="property_name"><a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream--size" title="The “size” property">size</a></td>
<td class="property_flags">Read / Write / Construct Only</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody><tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream-struct" title="GMemoryOutputStream">GMemoryOutputStream</a></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="screen">    <a href="../gobject-The-Base-Object-Type.html#GObject-struct">GObject</a>
    <span class="lineart">╰──</span> <a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a>
        <span class="lineart">╰──</span> GMemoryOutputStream
</pre>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.implemented-interfaces"></a><h2>Implemented Interfaces</h2>
<p>
GMemoryOutputStream implements
 <a class="link" href="GSeekable.html" title="GSeekable">GSeekable</a> and  <a class="link" href="GPollableOutputStream.html" title="GPollableOutputStream">GPollableOutputStream</a>.</p>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;gio/gio.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.description"></a><h2>Description</h2>
<p><a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> is a class for using arbitrary
memory chunks as output for GIO streaming output operations.</p>
<p>As of GLib 2.34, <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> trivially implements
<a class="link" href="GPollableOutputStream.html" title="GPollableOutputStream"><span class="type">GPollableOutputStream</span></a>: it always polls as ready.</p>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="GReallocFunc"></a><h3>GReallocFunc ()</h3>
<pre class="programlisting"><a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
<span class="c_punctuation">(</span>*GReallocFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
                 <em class="parameter"><code><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>);</pre>
<p>Changes the size of the memory block pointed to by <em class="parameter"><code>data</code></em>
 to
<em class="parameter"><code>size</code></em>
 bytes.</p>
<p>The function should have the same semantics as <code class="function">realloc()</code>.</p>
<div class="refsect3">
<a name="GReallocFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>memory block to reallocate</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>size to reallocate <em class="parameter"><code>data</code></em>
to</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="GReallocFunc.returns"></a><h4>Returns</h4>
<p> a pointer to the reallocated memory</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-new"></a><h3>g_memory_output_stream_new ()</h3>
<pre class="programlisting"><a class="link" href="GOutputStream.html" title="GOutputStream"><span class="returnvalue">GOutputStream</span></a> *
g_memory_output_stream_new (<em class="parameter"><code><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
                            <em class="parameter"><code><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>,
                            <em class="parameter"><code><a class="link" href="GMemoryOutputStream.html#GReallocFunc" title="GReallocFunc ()"><span class="type">GReallocFunc</span></a> realloc_function</code></em>,
                            <em class="parameter"><code><a href="../glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> destroy_function</code></em>);</pre>
<p>Creates a new <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a>.</p>
<p>In most cases this is not the function you want.  See
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-new-resizable" title="g_memory_output_stream_new_resizable ()"><code class="function">g_memory_output_stream_new_resizable()</code></a> instead.</p>
<p>If <em class="parameter"><code>data</code></em>
 is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the stream will use that for its internal storage.</p>
<p>If <em class="parameter"><code>realloc_fn</code></em>
 is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, it will be used for resizing the internal
storage when necessary and the stream will be considered resizable.
In that case, the stream will start out being (conceptually) empty.
<em class="parameter"><code>size</code></em>
 is used only as a hint for how big <em class="parameter"><code>data</code></em>
 is.  Specifically,
seeking to the end of a newly-created stream will seek to zero, not
<em class="parameter"><code>size</code></em>
.  Seeking past the end of the stream and then writing will
introduce a zero-filled gap.</p>
<p>If <em class="parameter"><code>realloc_fn</code></em>
 is <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then the stream is fixed-sized.  Seeking to
the end will seek to <em class="parameter"><code>size</code></em>
 exactly.  Writing past the end will give
an 'out of space' error.  Attempting to seek past the end will fail.
Unlike the resizable case, seeking to an offset within the stream and
writing will preserve the bytes passed in as <em class="parameter"><code>data</code></em>
 before that point
and will return them as part of <a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-steal-data" title="g_memory_output_stream_steal_data ()"><code class="function">g_memory_output_stream_steal_data()</code></a>.
If you intend to seek you should probably therefore ensure that <em class="parameter"><code>data</code></em>

is properly initialised.</p>
<p>It is probably only meaningful to provide <em class="parameter"><code>data</code></em>
 and <em class="parameter"><code>size</code></em>
 in the case
that you want a fixed-sized stream.  Put another way: if <em class="parameter"><code>realloc_fn</code></em>

is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then it makes most sense to give <em class="parameter"><code>data</code></em>
 as <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> and
<em class="parameter"><code>size</code></em>
 as 0 (allowing <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> to do the initial
allocation for itself).</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc slc">// a stream that can grow</span>
stream <span class="gtkdoc opt">=</span> <span class="function"><a href="GMemoryOutputStream.html#g-memory-output-stream-new">g_memory_output_stream_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> realloc<span class="gtkdoc opt">,</span> free<span class="gtkdoc opt">);</span>

<span class="gtkdoc slc">// another stream that can grow</span>
stream2 <span class="gtkdoc opt">=</span> <span class="function"><a href="GMemoryOutputStream.html#g-memory-output-stream-new">g_memory_output_stream_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> g_realloc<span class="gtkdoc opt">,</span> g_free<span class="gtkdoc opt">);</span>

<span class="gtkdoc slc">// a fixed-size stream</span>
data <span class="gtkdoc opt">=</span> <span class="function">malloc</span> <span class="gtkdoc opt">(</span><span class="number">200</span><span class="gtkdoc opt">);</span>
stream3 <span class="gtkdoc opt">=</span> <span class="function"><a href="GMemoryOutputStream.html#g-memory-output-stream-new">g_memory_output_stream_new</a></span> <span class="gtkdoc opt">(</span>data<span class="gtkdoc opt">,</span> <span class="number">200</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">,</span> free<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
<div class="refsect3">
<a name="g-memory-output-stream-new.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p> pointer to a chunk of memory to use, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>the size of <em class="parameter"><code>data</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>realloc_function</p></td>
<td class="parameter_description"><p> a function with <code class="function">realloc()</code> semantics (like <a href="../glib-Memory-Allocation.html#g-realloc"><code class="function">g_realloc()</code></a>)
to be called when <em class="parameter"><code>data</code></em>
needs to be grown, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>destroy_function</p></td>
<td class="parameter_description"><p> a function to be called on <em class="parameter"><code>data</code></em>
when the stream is
finalized, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-memory-output-stream-new.returns"></a><h4>Returns</h4>
<p> A newly created <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> object.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-new-resizable"></a><h3>g_memory_output_stream_new_resizable ()</h3>
<pre class="programlisting"><a class="link" href="GOutputStream.html" title="GOutputStream"><span class="returnvalue">GOutputStream</span></a> *
g_memory_output_stream_new_resizable (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Creates a new <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a>, using <a href="../glib-Memory-Allocation.html#g-realloc"><code class="function">g_realloc()</code></a> and <a href="../glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>
for memory allocation.</p>
<p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-get-data"></a><h3>g_memory_output_stream_get_data ()</h3>
<pre class="programlisting"><a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
g_memory_output_stream_get_data (<em class="parameter"><code><a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> *ostream</code></em>);</pre>
<p>Gets any loaded data from the <em class="parameter"><code>ostream</code></em>
.</p>
<p>Note that the returned pointer may become invalid on the next
write or truncate operation on the stream.</p>
<div class="refsect3">
<a name="g-memory-output-stream-get-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ostream</p></td>
<td class="parameter_description"><p>a <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-memory-output-stream-get-data.returns"></a><h4>Returns</h4>
<p> pointer to the stream's data, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the data
has been stolen. </p>
<p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-get-size"></a><h3>g_memory_output_stream_get_size ()</h3>
<pre class="programlisting"><a href="../glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
g_memory_output_stream_get_size (<em class="parameter"><code><a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> *ostream</code></em>);</pre>
<p>Gets the size of the currently allocated data area (available from
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-get-data" title="g_memory_output_stream_get_data ()"><code class="function">g_memory_output_stream_get_data()</code></a>).</p>
<p>You probably don't want to use this function on resizable streams.
See <a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-get-data-size" title="g_memory_output_stream_get_data_size ()"><code class="function">g_memory_output_stream_get_data_size()</code></a> instead.  For resizable
streams the size returned by this function is an implementation
detail and may be change at any time in response to operations on the
stream.</p>
<p>If the stream is fixed-sized (ie: no realloc was passed to
<a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-new" title="g_memory_output_stream_new ()"><code class="function">g_memory_output_stream_new()</code></a>) then this is the maximum size of the
stream and further writes will return <a class="link" href="gio-GIOError.html#G-IO-ERROR-NO-SPACE:CAPS"><code class="literal">G_IO_ERROR_NO_SPACE</code></a>.</p>
<p>In any case, if you want the number of bytes currently written to the
stream, use <a class="link" href="GMemoryOutputStream.html#g-memory-output-stream-get-data-size" title="g_memory_output_stream_get_data_size ()"><code class="function">g_memory_output_stream_get_data_size()</code></a>.</p>
<div class="refsect3">
<a name="g-memory-output-stream-get-size.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ostream</p></td>
<td class="parameter_description"><p>a <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-memory-output-stream-get-size.returns"></a><h4>Returns</h4>
<p> the number of bytes allocated for the data buffer</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-get-data-size"></a><h3>g_memory_output_stream_get_data_size ()</h3>
<pre class="programlisting"><a href="../glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
g_memory_output_stream_get_data_size (<em class="parameter"><code><a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> *ostream</code></em>);</pre>
<p>Returns the number of bytes from the start up to including the last
byte written in the stream that has not been truncated away.</p>
<div class="refsect3">
<a name="g-memory-output-stream-get-data-size.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ostream</p></td>
<td class="parameter_description"><p>a <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-memory-output-stream-get-data-size.returns"></a><h4>Returns</h4>
<p> the number of bytes written to the stream</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-18.html#api-index-2.18">2.18</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-steal-data"></a><h3>g_memory_output_stream_steal_data ()</h3>
<pre class="programlisting"><a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
g_memory_output_stream_steal_data (<em class="parameter"><code><a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> *ostream</code></em>);</pre>
<p>Gets any loaded data from the <em class="parameter"><code>ostream</code></em>
. Ownership of the data
is transferred to the caller; when no longer needed it must be
freed using the free function set in <em class="parameter"><code>ostream</code></em>
's
<a class="link" href="GMemoryOutputStream.html#GMemoryOutputStream--destroy-function" title="The “destroy-function” property"><span class="type">“destroy-function”</span></a> property.</p>
<p><em class="parameter"><code>ostream</code></em>
 must be closed before calling this function.</p>
<div class="refsect3">
<a name="g-memory-output-stream-steal-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ostream</p></td>
<td class="parameter_description"><p>a <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-memory-output-stream-steal-data.returns"></a><h4>Returns</h4>
<p> the stream's data, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if it has previously
been stolen. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-memory-output-stream-steal-as-bytes"></a><h3>g_memory_output_stream_steal_as_bytes ()</h3>
<pre class="programlisting"><a href="../glib-Byte-Arrays.html#GBytes"><span class="returnvalue">GBytes</span></a> *
g_memory_output_stream_steal_as_bytes (<em class="parameter"><code><a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a> *ostream</code></em>);</pre>
<p>Returns data from the <em class="parameter"><code>ostream</code></em>
 as a <a href="../glib-Byte-Arrays.html#GBytes"><span class="type">GBytes</span></a>. <em class="parameter"><code>ostream</code></em>
 must be
closed before calling this function.</p>
<div class="refsect3">
<a name="g-memory-output-stream-steal-as-bytes.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ostream</p></td>
<td class="parameter_description"><p>a <a class="link" href="GMemoryOutputStream.html" title="GMemoryOutputStream"><span class="type">GMemoryOutputStream</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-memory-output-stream-steal-as-bytes.returns"></a><h4>Returns</h4>
<p> the stream's data. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-34.html#api-index-2.34">2.34</a></p>
</div>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GMemoryOutputStream-struct"></a><h3>GMemoryOutputStream</h3>
<pre class="programlisting">typedef struct _GMemoryOutputStream GMemoryOutputStream;</pre>
<p>Implements <a class="link" href="GOutputStream.html" title="GOutputStream"><span class="type">GOutputStream</span></a> for arbitrary memory chunks.</p>
</div>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.property-details"></a><h2>Property Details</h2>
<div class="refsect2">
<a name="GMemoryOutputStream--data"></a><h3>The <code class="literal">“data”</code> property</h3>
<pre class="programlisting">  “data”                     <a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a></pre>
<p>Pointer to buffer where data will be written.</p>
<p>Flags: Read / Write / Construct Only</p>
<p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GMemoryOutputStream--data-size"></a><h3>The <code class="literal">“data-size”</code> property</h3>
<pre class="programlisting">  “data-size”                <a href="../glib-Basic-Types.html#gulong"><span class="type">gulong</span></a></pre>
<p>Size of data written to the buffer.</p>
<p>Flags: Read</p>
<p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GMemoryOutputStream--destroy-function"></a><h3>The <code class="literal">“destroy-function”</code> property</h3>
<pre class="programlisting">  “destroy-function”         <a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a></pre>
<p>Function called with the buffer as argument when the stream is destroyed.</p>
<p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
<p>Flags: Read / Write / Construct Only</p>
<p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GMemoryOutputStream--realloc-function"></a><h3>The <code class="literal">“realloc-function”</code> property</h3>
<pre class="programlisting">  “realloc-function”         <a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a></pre>
<p>Function with realloc semantics called to enlarge the buffer.</p>
<p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
<p>Flags: Read / Write / Construct Only</p>
<p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GMemoryOutputStream--size"></a><h3>The <code class="literal">“size”</code> property</h3>
<pre class="programlisting">  “size”                     <a href="../glib-Basic-Types.html#gulong"><span class="type">gulong</span></a></pre>
<p>Current size of the data buffer.</p>
<p>Flags: Read / Write / Construct Only</p>
<p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
</div>
</div>
<div class="refsect1">
<a name="GMemoryOutputStream.see-also"></a><h2>See Also</h2>
<p><a class="link" href="GMemoryInputStream.html" title="GMemoryInputStream"><span class="type">GMemoryInputStream</span></a></p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>